import hashlib


class MD5Utils(object):

    @staticmethod
    def encrypt(origin_str):
        """MD5加密"""

        if origin_str is None or len(origin_str) == 0:
            return None
        hash_obj = hashlib.md5(origin_str.encode('utf-8'))
        return hash_obj.hexdigest()

    @staticmethod
    def encrypt_16(origin_str):
        """MD5加密截断保留前16位"""
        return MD5Utils.encrypt(origin_str)[8:-8]
